<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/popup/head.jsp"%>

<script type="text/javascript">

	$(document).ready(function() {
		$("#mainForm").validate();
	});

	function clickBtn(action){
		switch(action){
		case "save":
			  $("#mainForm").attr("action", "publish-info!save.action");
			  break;
			  
		case "back":
			  CE.close();
			  return;
		}

		 $("#mainForm").submit();  
	}

	function clickImgBtn(action,id){
		switch(action){
		case "upload":
			  $("#imgForm").attr("action", "image-storage!startUploadFile.action");
			  break;
			  
		case "delete":
			 $("#imgForm").attr("action", "image-storage!delete.action?imageStorageId="+id);
			 break;
		}

		$("#imgForm").submit();  
	}	
</script>


<div class="content"> 							
	<div class="form2">
				
	  <script>var menuSelected = "FUN004";</script>
	  <div class="pageTitle">Publish Information - Create</div><br>
	  
	  <s:actionerror/>
	  <s:fielderror/>
	  <s:actionmessage/> 
	  
	  <s:form id="mainForm" name="mainForm" namespace="/publish" action="publish-info.action" validate="true" method="post" enctype="multipart/form-data">
	  	<s:hidden name="infoPublish.id"></s:hidden>
	  	
	    <table border="0" cellspacing="0" cellpadding="0">
	      <tr>
	        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
	        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
	      </tr>
	      <tr>
	          <td>
	        	  <label class="fLabel" >发布类型</label>
		          <div class="fField">
		            <s:select cssClass="inputSelect" cssStyle="width:155px" name="infoPublish.type" 
		            		  list="parameterManager.getByCode('PUBLISH_TYPE')" listKey="value" listValue="label"
		            		  headerKey="" headerValue="-- Select --">
		            </s:select>
		          </div>
	          </td>
	        <td><label class="fLabel" >标题</label>
	          <div class="fField">
	             <s:textfield name="infoPublish.title" cssStyle="width:150px" />
	          </div></td>
	    
	      </tr>
	      <tr>
	          <td colspan="2"><label class="fLabel" >联系方式</label>
		          <div class="fField">
		          	<s:textfield name="infoPublish.contactWay" cssStyle="width:150px" />
		          </div>
	          </td>
	          
	      </tr>    
	      <tr>
	        <td colspan="2"><label class="fLabel" >发布信息</label>
	          <div class="fField">
	            <s:textarea cssStyle="width:500px; height:100px" name="infoPublish.content" cssClass="inputTextarea"></s:textarea>
	          </div></td>
	          
	      </tr>
	    </table>
	    
	    <div class="btnSet btnSetTypeA">
	      <div class="left" >
	        <div class="button" >
	          <div class="left" >
	            <div class="right" >
	              <input class="inputButton" type="button" id="saveBtn" name="save" value="保存" onclick="clickBtn('save')"/>
	            </div>
	          </div>
	        </div>
	        <div class="button" >
	          <div class="left" >
	            <div class="right" >
	              <input class="inputButton" type="reset"" id="resetBtn" name="resetBtn" value="重置"/>
	            </div>
	          </div>
	        </div>
	        
			<div class="button">
	           <div class="left">
	             <div class="right">
	               <input type="button" onclick="clickBtn('back')" value="关闭" name="" id="" class="inputButton">
	             </div>
	           </div>
	         </div> 
	           
	      </div>
	    </div>
	   </s:form>
	
	  <s:if test="infoPublish!=null&&infoPublish.id!=null">
		  <s:form id="imgForm" action="image-storage!startUploadFile.action" method="post" enctype="multipart/form-data">
		  
		   <table border="0" cellspacing="0" cellpadding="0">
		      <s:if test="infoPublish.imageStorages!=null&&infoPublish.imageStorages.size()>0">
		      	<s:iterator value="infoPublish.imageStorages" var="imageStorage" status="sta">
				      <tr>
				      	<td><img src="image-storage!viewOne.action?imageStorageId=<s:property value='#imageStorage.id'/>" style="border: 0;"/></td>
				     	<td>
						    <div class="btnSet btnSetTypeA">
						      <div class="left" >
						        <div class="button" >
						          <div class="left" >
						            <div class="right" >
						              <input class="inputButton" type="button" id="deleteImgBtn" name="deleteImgBtn" value="删除图片" onclick="clickImgBtn('delete','<s:property value='#imageStorage.id'/>');"/>
						            </div>
						          </div>
						        </div>
						      </div>
						    </div>				     	
				     	</td>
				      </tr>	      	
		      	</s:iterator>
		      </s:if>
		      </table>
		      
		      <br><br><br>
			      <div>
			            <input type="hidden" name="infoPublishId" value="<s:property value='infoPublish.id'/>" />
					    <input type="file" name="file" />
					
					    <div class="btnSet btnSetTypeA">
					      <div class="left" >
					        <div class="button" >
					          <div class="left" >
					            <div class="right" >
					              <input class="inputButton" type="button" id="uploadBtn" name="upload" value="上传图片" onclick="clickImgBtn('upload')"/>
					            </div>
					          </div>
					        </div>
					      </div>
					</div>
			     </div>
	     </s:form>
     </s:if>
     
	</div>
</div>
    
<%@ include file="/common/popup/foot.jsp"%>    